<template>
	<view class="shop-address">
		<view class="box">
			<!-- <map style="width: 100%; height: 725upx;" @tap='changeMap' :latitude="latitude" :longitude="longitude" :markers="covers"
			 :clickable="true">
			</map> -->
			<view class="selectAddress">
				<view class="select">
					<text>经营地区</text>
					<view>
						<text @click="checkAddress">{{storeMsg.addres}}</text>
						<image src="/static/imgs/shopDetails/btn_01.png"></image>
					</view>
				</view>
				<view class="write">
					<text>详细地址</text>
					<textarea v-model="storeMsg.addres_detail" placeholder="请填写详细地址,如街道门牌号等" placeholder-style="color: #999"/>
					</view>
			</view>
			<view class="btn">
				 <button type="primary" @click="onConfirm">确认</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				storeMsg: {},
				address: '请选择经营地址', // 区域地址
				detailAddress: '', // 详细地址
				title: 'map',
				long: '', //经度
				lat: '', //纬度
				latitude: 22.602,
				longitude: 114.122,
				covers: [{
					latitude: 22.602,
					longitude: 114.122,
					iconPath: '/static/imgs/shopDetails/btn_02.png',
					//文本气泡样式  图片加不进去
					callout:{
						content:'深圳市布吉上水径一街',//文本
						color:'#333333',//文本颜色
						fontSize:12,
						anchorX:0,//label的坐标，原点是 marker 对应的经纬度
						anchorY:0,//label的坐标，原点是 marker 对应的经纬度 
						// x:39.909,//这个组件微信在1.2.0以后就废弃了
						// y:116.39742,
						bgColor:'#ffffff',//背景色
						padding:5,//文本边缘留白
						borderWidth:1,//边框宽度
						// borderColor:'#D84C29',//边框颜色							
						textAlign:'conter',//文本对齐方式。
						borderRadius:5,
					},
				}, ],

			}
		},
		onShow() {
			this.storeMsg = uni.getStorageSync('lph-storeInfo');
		},
		// uni.setStorageSync('lph-storeInfo',this.storeMsg);
		methods: {
			async onConfirm() { // 提交
				let a = {
					addres: this.storeMsg.addres,
					addres_detail: this.storeMsg.addres_detail,
					lng: this.storeMsg.lng,
					lat: this.storeMsg.lat,
				}
				let b = await this.$http.setShopBusinessAddress(a);
				if(b.code == 200) {
					uni.setStorageSync('lph-storeInfo',this.storeMsg);
					uni.showToast({
						title: b.message,
						icon: 'none'
					})
					setTimeout(() => {
						uni.navigateBack();
					},500)
					return
				}
				uni.showToast({
					title: b.message,
					icon: 'none'
				})
			},
			checkAddress() { // 选择地址
				uni.chooseLocation({
					success: (res) => {
						console.log(res)
						this.storeMsg.lng = res.longitude;
						this.storeMsg.lat = res.latitude;
						// this.address = res.name;
						this.storeMsg.addres = res.name;
						uni.setStorageSync('lph-storeInfo',this.storeMsg);
						console.log(this.storeMsg);
					}
				})
			},
			changeMap(e){
				console.log(e)
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	@import 'static/css/myStore.scss';
</style>
